package com.cabinet.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cabinet.service.IUserLoginService;
import com.cabinet.service.IUserService;
import com.cabinet.service.dao.UserDao;
import com.cabinet.web.entity.User;

@Service
public class UserService implements IUserLoginService,IUserService{
	@Autowired
	private UserDao udao;



	@Override
	public Boolean userLogin(String account, String password) {
		// TODO Auto-generated method stub
		User u = udao.getUserByUserAccountAndUserPassword(account, password);
		Boolean bool = false;
		if(u == null){
			bool = false;
		}else{
			bool = true;
		}
		return bool;
	}



	@Override
	public List<User> getUser() {
		// TODO Auto-generated method stub
		return udao.findAll();
	}



	@Override
	public User getUser(Long id) {
		// TODO Auto-generated method stub
		return udao.findOne(id);
	}



	@Override
	public User getUser(String count) {
		// TODO Auto-generated method stub
		return udao.getUserByUserAccount(count);
	}



	@Override
	public void addUser(User u) {
		// TODO Auto-generated method stub
		udao.save(u);
	}



	@Override
	public void deleteUser(User u) {
		// TODO Auto-generated method stub
		udao.delete(u);
	}



	@Override
	public User GetUserByAccountAndPassword(String account, String password) {
		// TODO Auto-generated method stub
		return udao.getUserByUserAccountAndUserPassword(account, password);
	}



	@Override
	public User getUserByOpenid(String openId) {
		// TODO Auto-generated method stub
		return udao.getUserByOpenid(openId);
	}




}
